package com.tuling.mall.feign.config;

import com.tuling.mall.feign.interceptor.FeignAuthRequestInterceptor;
import feign.Contract;
import feign.Logger;
import feign.Request;
import feign.RequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
public class FeignConfig {


    @Bean
    public Logger.Level feignLoggerLevel(){
        return Logger.Level.FULL;
    }

    @Bean
    public Request.Options options(){
        return new Request.Options(5000, TimeUnit.MILLISECONDS,10000,TimeUnit.MILLISECONDS,true);
    }

    /**
     * 修改契约配置，支持Feign原生的注解
     */
    public Contract contract(){
        return new Contract.Default();
    }

    @Bean
    public RequestInterceptor feignAuthRequestInterceptor(){
        return new FeignAuthRequestInterceptor();
    }
}
